import { FMVCS } from "../../fgui/fmvc/FMVCS";
import MapCreateData from "./MapCreateData";
import { GlobalEvent } from "../global/Global";
import Manager from "../../manager/Manager";
import { ConstDefine } from "../common/ConstDefine";
import MapCreateView from "./MapCreateView";

export default class MapCreateCtrl extends FMVCS.FCtrl {
    /** 数据实体 */
    static data: MapCreateData = null;

    constructor() {
        super();
        MapCreateCtrl.data = new MapCreateData();
    }

    /** 事件监听注册 */
    rigisterEventListener(){
        this.on(GlobalEvent.UIListenID.UI_BtnMapCreate_Click, this.onMapNewCreate, this);
        this.on(GlobalEvent.UIListenID.UI_MapRevisions, this.onMapRevisions, this);
    }

    /** 创建新地图 */
    onMapNewCreate(){
        MapCreateCtrl.data.vo.isNewMap = true;
        this.onOpenView();
    }

    /** 地图修改 */
    onMapRevisions(map: ConstDefine.Config.StarConfig){
        MapCreateCtrl.data.vo.isNewMap = false;
        MapCreateCtrl.data.vo.revisionMap = map;

        this.onOpenView();
    }

    onOpenView(){
        Manager.fui.open(ConstDefine.UI.MapCreateView, MapCreateView);
    }


}
